#ifndef QQMUSIC_H
#define QQMUSIC_H

#include <QWidget>
#include<QJsonObject>
#include"volumetool.h"
#include"musiclist.h"
#include<QMediaPlayer>
#include<QMediaPlaylist>
#include"commonpage.h"
#include"lrcpage.h"
#include<QPropertyAnimation>
#include<QSqlDatabase>

QT_BEGIN_NAMESPACE
namespace Ui { class QQMusic; }
QT_END_NAMESPACE

class QQMusic : public QWidget
{
    Q_OBJECT

public:
    QQMusic(QWidget *parent = nullptr);
    ~QQMusic();

    void InitUI();
    void InitSqlite();
    void InitMusicList();//这里不加启动就会再数据库多加一组
    void initPlayer();
    void connectSignalsAndSlots();
    QJsonArray randomPicture();
    void playAllOfCommonPage(CommonPage* page,int index);

private slots:
    void on_exit_clicked();
    void quitQQMusic();
    void onMyFormClick(int pageId);

    void on_volume_clicked();

    void on_addLocal_clicked();

    void onupdataLikeMusic(bool isLike,const QString& musicId);
    void onPlayClicked();
    void onStateChanged();
    void onPlaybackModeClicked();
    void onPlayUp();
    void onPlayDown();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);
    void onPlayAll(PageType pageType);
    void onPlayMusicByIndex(CommonPage* page,int index);
    void onCurrentIndexChanged(int index);
    void onSetMusicSilence(bool isMuted);
    void onSetMusicVolume(int volume);
    void onDurationChanged(qint64 duration);
    void onPositionChanged(qint64 duration);

    void onMusicSliderChanged(float ratio);
    void onMetaDataAvailableChangedChanged(bool available);
    void onLrcWordClicked();
    void on_min_clicked();

    void on_skin_clicked();

    void updateMyformAnimal();

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);


private:
    Ui::QQMusic *ui;
    QPoint dragPosition;//记录光标相对于窗⼝标题栏的相对距离
    VolumeTool* volume;
    MusicList musicList;
    QMediaPlayer* player;
    QMediaPlaylist* playList;
    CommonPage* currentPage;
    qint64 totalDuration;
    int currentPlayMusicIndex;
    LrcPage* lrcPage;
    QPropertyAnimation* lrcAnimation;
    QSqlDatabase sqlite;
    bool isDrag;
};
#endif // QQMUSIC_H
